<?php
namespace Zhub\HttpMessage\Headers;

use Zhub\DataStruct\Struct;

class Cookie extends Struct
{
	const KEY = 'key';

	const VALUE = 'value';

	const EXPIRES = 'expires';

	const PATH = 'path';

	const DOMAIN = 'domain';

	const SECURE = 'secure';

	const HTTP_ONLY = 'httpOnly';

	private static $instance = null;

    public static function instance(string $key, string $value)
    {
        if (!self::$instance) {
            self::$instance = new self();
        }

        $instance = clone self::$instance;
        $instance->clear();
        $instance->setKey($key);
        $instance->setValue($value);

        return $instance;
    }

	public function getKey():string
	{
		return $this->get(self::KEY);
	}

	public function setKey(string $key)
	{
		$this->set(self::KEY, $key);
		return $this;
	}

	public function getValue():string
	{
		return $this->get(self::VALUE);
	}

	public function setValue(string $value)
	{
		$this->set(self::VALUE, $value);
        return $this;
	}

	public function getExpires():?int
	{
		return $this->get(self::EXPIRES);
	}

	public function setExpires(int $expires)
	{
		$this->set(self::EXPIRES, $expires);
        return $this;
	}

	public function getPath():?string
	{
		return $this->get(self::PATH);
	}

	public function setPath(string $path)
	{
		$this->set(self::PATH, $path);
        return $this;
	}

	public function getDomain():?string
	{
		return $this->get(self::DOMAIN);
	}

	public function setDomain(string $domain)
	{
		$this->set(self::DOMAIN, $domain);
        return $this;
	}

	public function getSecure():?bool
	{
		return $this->get(self::SECURE);
	}

	public function setSecure(bool $secure)
	{
		$this->set(self::SECURE, $secure);
        return $this;
	}

	public function getHttpOnly():?bool
	{
		return $this->get(self::HTTP_ONLY);
	}

	public function setHttpOnly(bool $httpOnly)
	{
		$this->set(self::HTTP_ONLY, $httpOnly);
        return $this;
	}

	public static function initialize():array
	{
		return [
			self::KEY => '',
			self::VALUE => '',
			self::EXPIRES => null,
			self::PATH => null,
			self::DOMAIN => null,
			self::SECURE => null,
			self::HTTP_ONLY => null,
	
		];
	}

}
